home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
text
/
misc
/
AmiToVMS.lha
/
AmiToVMS
/
source
/
AmiToVMS.c
Wrap
C/C++ Source or Header
|
1999-01-07
|
1KB
|
84 lines
/* Convert an Amiga text file to a VMS text file
Writted by Gregory Eycken - ANSI/C
Using quick'n'dirty method !
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(void)
{
FILE* fin;
FILE* fout;
char filename[81];
char destname[85];
char byte;
/* getting source filename
*/
printf("Please enter filename (max. 80) : ");
gets(filename);
/* opening source file
*/
if ((fin = fopen(filename, "r")) == NULL)
{
printf("Error : can't open source file.\n");
exit(1);
}
/* parsing destination filename
*/
strcpy(destname, filename);
strcat(destname, "_VMS");
/* creating destination file
*/
if ((fout = fopen(destname, "w")) == NULL)
{
printf("Error : can't open destination file.\n");
fclose(fin);
exit(1);
}
/* reading first byte
*/
byte = fgetc(fin);
while (byte != EOF)
{
/* converting Amiga -> VMS
*/
if (byte == 0x0A)
{
if (fputc(0x0D, fout) != 0x0D)
{
printf("Error while writing.\n");
fclose(fin);
fclose(fout);
exit(1);
}
}
/* writing the byte
*/
if (fputc(byte, fout) != byte)
{
printf("Error while writing.\n");
fclose(fin);
fclose(fout);
exit(1);
}
/* reading next byte
*/
byte = fgetc(fin);
}
/* end of while */
fclose(fin);
fclose(fout);
exit(0);
}